package com.baizhi.service.Impl;

import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import com.baizhi.mapper.UserMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpSession;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public boolean selectByEmail(User user, HttpSession session) {
        boolean b = false;
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("email",user.getEmail());
        queryWrapper.eq("password",user.getPassword());
        User user1 = userMapper.selectOne(queryWrapper);
        if(user1!=null){
            session.setAttribute("user",user1);
            b = true;
        }
        return b;
    }
}
